#ifdef _DEBUG

#include "../PreHeader.h"

void DEBUG_INIT()
{
/*#ifdef IPL_DEBUGFONT_INCLUDED
    spDebugFontInfo = IPLDebugFont_GetFontInfo();

    glGenTextures(1,&sDebugFontTextureName);
    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, sDebugFontTextureName);

    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, spDebugFontInfo->mpTextureInfo->mTextureFormat,
            spDebugFontInfo->mpTextureInfo->mTextureWidth, spDebugFontInfo->mpTextureInfo->mTextureHeight, 0,
            spDebugFontInfo->mpTextureInfo->mTextureFormat, spDebugFontInfo->mpTextureInfo->mTextureType, 
            spDebugFontInfo->mpTextureInfo->mpImageData);

    GLenum format = spDebugFontInfo->mpTextureInfo->mTextureFormat;
    GLenum type   = spDebugFontInfo->mpTextureInfo->mTextureType;

    sbDebugFontNeedsColorAttrib  = false;
    sbDebugFontNeedsColorUniform = false;

    switch(type)
    {
        case GL_UNSIGNED_SHORT_4_4_4_4:
            sDebugFontShaderID          = IPL_BSV_4444NEARESTBLENDING;//FP;
            IPL_ASSERT(format == GL_RGBA,"Bad format/type combination '%d/%d'",format,type);
            break;

        case GL_UNSIGNED_SHORT_5_5_5_1:
            sDebugFontShaderID          = IPL_BSV_5551NEARESTBLENDING;//FP;
            IPL_ASSERT(format == GL_RGBA,"Bad format/type combination '%d/%d'",format,type);
            break;

        case GL_UNSIGNED_SHORT_5_6_5:
            sDebugFontShaderID          = IPL_BSV_565NEAREST;//FP;
            IPL_ASSERT(format == GL_RGB,"Bad format/type combination '%d/%d'",format,type);
            break;

        case GL_UNSIGNED_BYTE:
            switch(format)
            {
                case GL_RGBA:
                    sDebugFontShaderID = IPL_BSV_8888NEAREST;//FP;
                    break;

                case GL_LUMINANCE_ALPHA:
                    sDebugFontShaderID = IPL_BSV_L8A8LINEARMODWITHCOLORBLENDING;//FP;
                    sbDebugFontNeedsColorAttrib = true;
                    break;

                case GL_ALPHA:
                    sDebugFontShaderID = IPL_BSV_A8NEARESTMODWITHCOLORBLENDING;//FP;
                    sbDebugFontNeedsColorAttrib = true;
                    break;

                case GL_LUMINANCE:
                    sDebugFontShaderID = IPL_BSV_SPHEREMAP_L8LINEARMODWITHUNIFORM;
                    sbDebugFontNeedsColorUniform = true;
                    break;

                default:
                    IPL_ASSERT(0,"Unknown texture format '%d'",format);
                    break;
            }
            break;

        default:
            IPL_ASSERT(0,"Unknown texture type '%d'",type);
            break;
    }
#endif
	*/
}

void DEBUG_UPDATE()
{
/*
#ifdef IPL_DEBUG_USE_CONSOLE
	if(gp_GameApp->moKeypad.IsKeyPressed(KEYPAD_PAUSE))
	{
		sUseDebug = !sUseDebug;
	}
	
  // This call is necessary to allow the console library to add the currently
  // visible console messages to the message pool for rendering in the render
  // handler below.
	IPLConsole_SetVisibility(false);
	IPLConsole_Update();
#endif
	*/
}

void DEBUG_RENDER()
{
	/*
#if (defined IPL_DEBUG_USE_MESSAGE_POOL && defined IPL_DEBUGFONT_INCLUDED) 

    // Save the state of the matrix stack
    GLint matrix_mode;
    IPLGLMatrixStack_GetIntegerv(IPL_MSE_MATRIX_MODE,&matrix_mode);
    IPLGLMatrixStack_PushMatrix();
    IPLGLMatrixStack_MatrixMode(matrix_mode == IPL_MSE_PROJECTION ? IPL_MSE_MODELVIEW : IPL_MSE_PROJECTION);
    IPLGLMatrixStack_PushMatrix();

    // Set up matrices for debug font rendering
    IPLGLMatrixStack_MatrixMode(IPL_MSE_PROJECTION);
    IPLGLMatrixStack_LoadMatrixx(IPL_STANDARD_ORTHO_MATRIX);

    IPLGLMatrixStack_MatrixMode(IPL_MSE_MODELVIEW);
    IPLGLMatrixStack_LoadIdentity();

#ifdef IPL_DEBUG_USE_CONSOLE
    // Draw Console BG Rect
    if (IPLConsole_GetVisibility())
    {
        tIPLGeometry geom;

        tIPLRect  rect;
        IPLConsole_GetRect(&rect);

        rect.mX -= CONSOLE_BORDER_SPACING;
        rect.mY += CONSOLE_BORDER_SPACING;
        rect.mW += CONSOLE_BORDER_SPACING * 2;
        rect.mH += CONSOLE_BORDER_SPACING * 2;

        __IPLMain_gen_bordered_rect(&geom, &rect, CONSOLE_ALPHA, CONSOLE_BORDER_WIDTH);

        IPLGLStateVector_SetCurrentToBuiltin( IPL_BSV_COLORBLENDING );//IPL_BSV_COLORBLENDINGFP

        //glUniformMatrix4xvAPPLE(0, 1, GL_FALSE, IPLGLMatrixStack_GetMVPx());

       // glEnableVertexAttribArray(0);
       // glVertexAttribPointer(0, 4, GL_FIXED, GL_FALSE, 0, geom.mpVertexPositions);

        //glEnableVertexAttribArray(1);
        //glVertexAttribPointer(1, 4, GL_FIXED, GL_FALSE, 0, geom.mpVertexColors);

        //glDrawArrays(geom.mGeometryMode, 0, geom.mCount);

		//tIPLGeometry  geom;
		//geom.mGeometryMode     = GL_QUADS;
		//geom.mCount            = 4;
		//geom.mpVertexPositions = vertices;
		//geom.mpVertexColors    = NULL;
		//geom.mpTextureCoords   = texCoord;
		//	IPLGLUtil_SetUniformColor4xv(color);
		IPLGeometry_DrawDirect(&geom);
    }
#endif

    // Draw first pass messages, msgs from update + console msgs
    __IPLMain_DrawMessages( 1.0f, 1.0f, 1.0f, 1.0f );

    // Generate memory manager stat messages
    if(sUseDebug)  IPLMemoryMgr_DisplayStats(IPLMath_IntToFixed(210),IPLMath_IntToFixed(200));
    // Draw second-pass messages, memory stats
    __IPLMain_DrawMessages(1.0f, 0,0,1.0f);

    // Restore the matrix stack to its previous state
    IPLGLMatrixStack_PopMatrix();
    IPLGLMatrixStack_MatrixMode(IPL_MSE_PROJECTION);
    IPLGLMatrixStack_PopMatrix();
    IPLGLMatrixStack_MatrixMode(matrix_mode);
#endif
	*/
}

void DEBUG_EXIT()
{
	/*
#ifdef IPL_DEBUG_USE_CONSOLE
    IPLConsole_Destroy();
#endif

#ifdef IPL_DEBUG_USE_MESSAGE_POOL
    // Clear out the message pool and destroy it
    GLfloat x;
    GLfloat y;

    while (IPLMessagePool_PopMessage(&x,&y)) ;

    IPLMessagePool_DestroyPool();
#endif
	LOG_FLUSH();
	*/
}
void DEBUG_RESET()
{
	/*
    IPLMessagePool_Reset();
    if (IPLConsole_GetVisibility())
		IPLConsole_Clear();
		*/
}


#endif // _DEBUG
